package demo;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: syyyy
 * Date: 2025-07-11
 * Time: 17:12
 */
public class Test2 {
    public static void main(String[] args) {
        //将String->为StringBulider或者StringBuffer
        String s="abc";
        StringBuilder stringBuilder=new StringBuilder(s);
        StringBuffer stringBuffer=new StringBuffer(s);

        String str = "World";
        // 方式1：链式调用
        StringBuilder sb = new StringBuilder().append(str);
        // 方式2：分步调用
        StringBuilder sb2 = new StringBuilder();
        sb2.append(str);




        //将StringBulider或者StringBuffer转换为String
        System.out.println(stringBuffer.toString());
    }
}
